package com.stagechatserver.chatserver.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.stagechatserver.chatserver.mapper.ChatMapper;
import com.stagechatserver.chatserver.service.ChatService;
import com.stagecommon.common.pojo.Chat;
import com.stagecommon.common.pojo.RespBean;
import com.stagecommon.common.vo.ChatVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
public class ChatServiceImpl extends ServiceImpl<ChatMapper, Chat> implements ChatService {

    @Resource
    private ChatMapper chatMapper;

    @Override
    public void saveMessage(Integer fromId, Integer receiver, String message) {
        Chat chat = new Chat();
        chat.setCreatedTime(LocalDateTime.now());
        chat.setSender(fromId);
        chat.setReceiver(receiver);
        chat.setMessage(message);
        chat.setSessionType((byte)1);
        chatMapper.insert(chat);
    }

//    @Override
//    public RespBean<List<ChatVo>> getSession(Integer fromId, Integer receiver) {
//        return RespBean.operationSuccess(200,"获取成功",chatMapper.getSessionByFromIdAndReceiver(fromId, receiver));
//    }


}
